import api from '@/fetch/api'

export default {
  data () {
    return {
      username: '',
      password: '',
      activeType: 'IN'
    }
  },
  methods: {
    handleFocus (item) {
      this.$refs[item].className = 'form_item_input is_input'
    },
    handleBlue (item) {
      this.$refs[item].className = 'form_item_input'
    },
    changeTab (item) {
      this.activeType = item
    },
    routerToMd () {
      this.$router.push('/md');
    },
    handleLogin () {
      if (!this.username) {
        this.$message({
          message: '请输入用户名',
          type: 'warning'
        })
        return
      }
      if (!this.password) {
        this.$message({
          message: '请输入密码',
          type: 'warning'
        })
        return
      }

      api.post('login', {
        username: this.username,
        password: this.password
      }).then(data => {
        this.$router.push('/home')
      })
    }
  }
}
